<template>
  <div>
    <div class="answers_list pad_b20" >
      <!-- v-if="activeName==item.category_id" -->
      <div class="ans_item" v-for="(item,index) in list" v-if="!item.is_jump" :key="index" >
        <div class="cate_tt" v-if="item.cate_tt">{{item.cate_tt}}</div>
        <div class="item" :id="'item'+index" >
          <div class="tt flex">
            <div class="flex_s">
              <span class="ans_type">{{type_text[item.type] || '未知'}}</span>
              <span style="color: #056DFF;" v-if="is_view">【得{{item.df_score}}分】</span>
              <span class="margin_l10">{{index+1}}. </span>
            </div>
            <div class="flex1 margin_l10">
              <div class="answer_tt" v-html="item.title"></div>
            </div>
          </div>
          <div class=" " v-if="item.kh_notice">
            <el-alert :title="item.kh_notice" type="warning" show-icon :closable="false"></el-alert>
          </div>
          <div class="ans flex_ac  flex_w pad_tb10" v-if="item.type==1 || item.type==2">
            <div style="margin-right: 30px;" class="flex_ac"  v-for="(item2,index2) in item.answer" :key="item2.id">
              <div class="item_d flex_ac" @click="sele_this(index,index2)">
                <div class="moni_radio " :class="[item2.is_sele?'active':'',item.type==1?'':'check']"></div>
                {{item2.answer_title}}
                <span style="color: #056DFF;" v-if="is_view && item2.is_sele && item2.is_open==1">【开放：{{item2.constant}}】</span>
              </div>
              <div class="pad_tb10 flex_ac" v-if="item2.is_open==1 && item2.is_sele && !is_view">
                <!-- @blur="check_emp(index,index2,item.constant)" -->
                <div class="margin_lr10 flex_s" style="color: #056DFF;">开放选项</div><el-input placeholder="" class="line_input" style="width: 150px;"  type="text" maxlength="500" v-model="item2.constant"></el-input>
                <!-- <div class="error_tip" v-if="item.is_error">
                    {{item.is_error}}
                </div> -->
              </div>
            </div>
          </div>
          <template  v-if="!is_view">
            <div class="ans  flex_w flex " v-if="item.type==3 || item.type==4">
              <div v-for="(item2,index2) in item.answer" :key="item2.id">
                <div class="pad_tb10 margin_r20 flex_ac">
                  <div v-if="item.type==3" class="flex_s">{{item2.answer_title}}：</div>
                  <el-input  :placeholder="'请输入'" class="line_input" @blur="get_jump(index)" :style="{width:item.type==3?'150px':'400px'}"  :type="item.type==3?'input':'textarea'" maxlength="500" v-model="item2.constant"></el-input>
                </div>
              </div>
            </div>
          </template>
          <template v-else>
            <div class="pad_b10 ans_it" v-if="item.type==3 || item.type==4">
              <div v-for="(item2,index2) in item.answer" :key="item2.id">
               {{item2.answer_title}}： {{item2.constant}}
              </div>
            </div>
          </template>

          <div class="up_div " v-if="in_arr(index,1,1).length>0">
            <div class="flex_ac pad_b10" v-if="!is_view">
              <div>上传附件：</div>
              <a href="javascript:;" class="upbtn" v-if="in_arr(index,1)" @click="unload_file(index,1)"><img src="@/assets/pinggu/upicon.png" alt="">上传图片</a>
              <a href="javascript:;" class="upbtn" v-if="in_arr(index,2)" @click="unload_file(index,2)"><img src="@/assets/pinggu/upicon.png" alt="">上传视频</a>
              <a href="javascript:;" class="upbtn" v-if="in_arr(index,3)" @click="unload_file(index,3)"><img src="@/assets/pinggu/upicon.png" alt="">上传文档</a>
              <a href="javascript:;" class="upbtn" v-if="in_arr(index,4)" @click="unload_file(index,4)"><img src="@/assets/pinggu/upicon.png" alt="">上传压缩包</a>

            </div>
            <div class="flex pdflist pad_b10" v-if="item.files.length>0">
              <div class="pdfitem flex_ac" v-for="(item3,index3) in item.files" :key="index3">
                <img src="@/assets/pinggu/up1.png" v-if="item3.type==1" class="icon margin_r10" alt="">
                <img src="@/assets/pinggu/up3.png" v-if="item3.type==2" class="icon margin_r10" alt="">
                <img src="@/assets/pinggu/up2.png" v-if="item3.type==3" class="icon margin_r10" alt="">
                <img src="@/assets/pinggu/up4.png" v-if="item3.type==4" class="icon margin_r10" alt="">
                <div class="flex1">{{item3.file_name}}</div>
                <div v-if="item3.store_path" class="flex_ac flex_s">
                  <a href="javascript:;" class="op_btn" @click="view_file(item3.store_path,item3.file_name)"><img src="@/assets/pinggu/fileop1.png" alt="">查看</a>
                  <a href="javascript:;" class="op_btn" @click="download(item3.store_path,item3.file_name)"><img src="@/assets/pinggu/fileop3.png" alt="">下载</a>
                  <a href="javascript:;" class="op_btn" v-if="!is_view" @click="list[index].files.splice(index3,1)"><img src="@/assets/pinggu/fileop2.png" alt="">删除</a>
                </div>
              </div>
            </div>
          </div>

          <div style="text-align: center; width: 100%;" v-if="item.answer.length==0">
            <Nodata text="暂无选项" />
          </div>
        </div>

      </div>
    </div>
    <Nodata v-if="list.length==0" text="暂无数据" />

    <!-- 上传图片预览 -->
    <el-dialog title="查看附件" :close-on-click-modal="false" append-to-body @closed="uploadImageUrl=''" width="800px" :visible.sync="uploadImgVisible">
      <img style="width: 100%;" :src="uploadImageUrl" v-if="get_file_type(uploadImageUrl)=='image'" alt="">
      <video :src="uploadImageUrl" controls autoplay style="width: 100%; height: 450px;"  v-if="get_file_type(uploadImageUrl)=='video'"></video>
      <div class="pad_t20"></div>
    </el-dialog>
    <!-- 预览图片 -->
    <uploadfile ref="upload_file" :accept="accept" :limit="9" :multiple="true" @handleUploadSuccess="handleUploadSuccess" />
    <FilePreviewer ref="FilePreviewerRef"/>
  </div>
</template>

<script>
import $ from "jquery";
// 上传组件
import uploadfile from "@/components/upload_file";
import FilePreviewer from '@/components/viewfile.vue'
export default {
  name: 'shopList',
  components: {uploadfile,FilePreviewer},
  data () {
    return {
      loading:true,
      is_ajax:false,
      show_filter:true,
      is_close:false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      total: 0,
      // 定时任务表格数据
      list: [],
      // 查询参数
      queryParams: {
        page: 1,
        page_size: 10000000,
        keywords: undefined
      },
      statusOptions: [{label:'启用',value:'0'},{label:'停用',value:'1'}],
      openOptions: [{label:'当前页面打开',value:0},{label:'新页面打开',value:1}],
      open:false,
      radio:'',
      uploadImgVisible:false,
      video_url:"",
      checked:false,
      title:'',
      types:[],
      type_text:{1:'单选',2:'多选',3:'填空',4:'描述',5:'矩阵单选题',6:'矩阵多选题',7:'矩阵填空题'},
      show_ans:false,
      activeName:'0',
      cate:[],
      uploadImageUrl:'',
      accept:'',
      template_type:'', //1 题库预览， 2 项目预览答题， 3，样本答题结果查看,, 4 机构端答题
      is_view:false, //是否是查看
    }
  },
  created() {


  },
  methods:{
    init(data){
      console.log(data)
      this.id=data.id || '';
      this.project_id=data.project_id || '';
      this.title=data.title || '';
      this.template_type =data.type || 1;
      this.is_view=false;
      this.old_answers=data.answer_list || [];

      if(this.template_type==3){
        this.is_view=true
        this.deal_list2(data.list)
      }else{
        this.is_view=data.is_view==1?true:false;
        this.getList();
      }

    },
    deal_list2(datalist){
      console.log(datalist)
      const _this=this;
      let list=[];
      let category_id=''
      for(let i=0;i<datalist.length;i++){
        if(datalist[i].category_title!=category_id){
          datalist[i].cate_tt=datalist[i].category_title;
          category_id=datalist[i].category_title;
        }
        datalist[i].files=datalist[i].main_annex.map(v=>{
          let obj={
            store_path:'storage/'+v.url.split('/storage/')[1],
            file_name:v.name,
            type:v.type
          }
          return obj
        })
        datalist[i].answer=datalist[i].answer.map(v=>{
          v.is_sele=v.is_choose==1?true:false;
          v.is_open=((datalist[i].type==1 || datalist[i].type==2) && v.constant)?1:0
          return v
        })
      }

      _this.list = datalist;
      _this.cate=datalist;
    },
    view_file(fileurl,name){
      let url=this.file_http+fileurl;
      const ext = fileurl.split('.').pop().toLowerCase()
      let fileType
      if (ext === 'pdf') {
        fileType = 'pdf'
      } else if (['doc', 'docx'].includes(ext)) {
        fileType = 'word'
      } else if (['xls', 'xlsx'].includes(ext)) {
        fileType = 'excel'
      } else if(['png', 'jpg','jpeg','mp4'].includes(ext)) {
        fileType = 'image'
      }else{
        fileType = 'other'
      }
      if(fileType=='other'){
        this.download(url,name);
        return false;
      }else if(fileType=='pdf'){
        // 需要下载防止跨域，使用 本地代理
        url=this.http+fileurl;
      }else if(fileType=='word' || fileType=='excel'){
        // 全路径
      }else if(fileType=='image'){
        this.handleIMGSPreview(url)
        return false;
      }
      this.$refs.FilePreviewerRef.open(url)
    },
    async download(fileurl,name){
        const response = await fetch(this.http+fileurl);
        // 检查响应是否成功
        if (!response.ok) {
          throw new Error(`HTTP错误，状态码: ${response.status}`);
        }
        // 将响应转换为blob
        const blob = await response.blob();
        // 创建指向blob的URL
        const url = URL.createObjectURL(blob);

        // 创建a标签并触发下载
        const link = document.createElement('a');
        link.href = url;
        // +'.'+fileurl.split('.').pop()
        link.download =name; // 强制下载的关键属性
        document.body.appendChild(link);
        link.click();

        // 清理资源
        setTimeout(() => {
          document.body.removeChild(link);
          URL.revokeObjectURL(url); // 释放blob URL
        }, 100);

    },
    handleIMGSPreview(item){
      this.uploadImageUrl=item;
      this.uploadImgVisible=true
    },
    get_file_type(path){
        let ext=path.split('.')[path.split('.').length-1].toLowerCase();
        if(ext=='mp4' || ext=='3gp'){
            return 'video'
        }else{
            return 'image'
        }
    },
    unload_file(index,type){
      this.upload_key=index;
      this.upload_type=type;
      if(type==1){
        this.accept='image/*'
      }else if(type==2){
        this.accept='video/*'
      }else if(type==3){
        this.accept='.pdf,.doc,.docx,.xls,.xlsx,.ppt,.pptx'
      }else if(type==4){
        this.accept='.zip,.rar,.7z,.tar'
      }
      console.log(this.accept)
      setTimeout(()=>{
        this.$nextTick(()=>{
          this.$refs.upload_file.init()
        })
      },50)

    },
    handleUploadSuccess(e){
      this.list[this.upload_key].files.push({store_path:e.message,file_name:e.file.name,type:this.upload_type})
    },

    in_arr(index,type,what){
        if(this.is_view){return ['']}

        let arr=[];
        let item=this.list[index];

        let main=(item.main_annex==='' || item.main_annex==0)?[]:item.main_annex.split(',');
        let cur=[];
        for(let i=0;i<item.answer.length;i++){
            if(item.answer[i].is_sele){
                let ann=item.answer[i].annex===''?[]:item.answer[i].annex.split(',');
                cur=cur.concat(ann)
            }
        }
        arr=main.concat(cur);

        if(what==1){
            return arr
        }else{
            let n=0;
            for(let i=0;i<arr.length;i++){
                if(arr[i]==type){
                    n++
                    break;
                }
            }
            return n>0?true:false
        }
    },
    get_ids(index,can_empty){
      let ids=[];
      let n=0;
      let answers=this.list[index].answer
      for(let i=0;i<answers.length;i++){
          if(answers[i].is_sele){
              if(this.list[index].type==3 || this.list[index].type==4){
                  if(answers[i].constant===''){
                    // answers[i].is_error='请输入';
                    n++
                  }
                  ids.push({
                      answer_id:answers[i].answer_id,
                      constant:answers[i].constant
                  })
              }else{
                if(answers[i].is_open==1){
                  if(answers[i].constant===''){
                    // answers[i].is_error='请输入';
                    n++
                  }
                }
                ids.push({
                    answer_id:answers[i].answer_id,
                    constant:answers[i].constant
                })
              }
          }
      }
      if(n==0){
         return ids
      }else{
        if(can_empty){
          return ids
        }else{
          return false;
        }

      }
    },
    try_submit(is_zc,form){
      const _this=this;
      _this.is_zc=is_zc;
      _this.info_form=form?{...form}:{};
      if(_this.is_ajax){return false;}
      let _data={}
      for(let i=0;i<this.list.length;i++){
        if(!this.list[i].is_jump){
          let ids=this.get_ids(i);
          console.log(ids)
          if(_this.is_zc!=1){
            if(!ids){
                _this.tip_show('请填写第'+(i+1)+'题文字内容','error')
                return false;
            }

            if(ids.length==0 && (this.list[i].type==1 || this.list[i].type==2)){
                _this.tip_show('请回答第'+(i+1)+'题','error')
                return false;
            }

            if(this.list[i].type==2 && ids.length<this.list[i].min_change){
              _this.tip_show('第'+(i+1)+'题选项不能少于'+this.list[i].min_change+'个','error')
              return false;
            }
            if(this.list[i].type==2 && ids.length>this.list[i].max_change){
              _this.tip_show('第'+(i+1)+'题选项不能大于'+this.list[i].max_change+'个','error')
              return false;
            }
          }
          let need_files=[];
          let need_type=[];
          if(!_this.is_view){
              for(let k=0;k<this.list[i].files.length;k++){
                  if(_this.in_arr(i,this.list[i].files[k].type)){
                      need_files.push(this.list[i].files[k])
                  }
              }
              need_type=_this.in_arr(i,1,1);
              if(_this.is_zc!=1){
                for(let t=0;t<need_type.length;t++){
                    if(!_this.have_file(need_type[t],need_files) && need_type[t]!=='' && need_type[t]!=0){
                        let a=need_type[t];
                        let texts={1:'图片',2:'视频',3:'文档',4:'压缩包'}
                        _this.tip_show('请补充第'+(i+1)+'题'+texts[a],'warning')
                        return false
                    }
                }
              }
              this.list[i].all_files=need_files;
          }
          this.list[i].ids=ids;
        }

      }

      for(let i=0;i<this.list.length;i++){
        if(!this.list[i].is_jump){
          _data['subject_answer['+i+'][subject_id]']=_this.list[i].id;
          let ids=this.list[i].ids;
          for(let k=0;k<ids.length;k++){
              _data['subject_answer['+i+'][answer_result]['+k+'][answer_id]']=ids[k].answer_id;
              _data['subject_answer['+i+'][answer_result]['+k+'][constant]']=ids[k].constant;
          }
          let all_files=this.list[i].all_files;
          for(let k=0;k<all_files.length;k++){
              // _data['subject_answer['+i+'][submit_annex]['+k+'][sample_id]']=all_files[k].sample_id;
              _data['subject_answer['+i+'][submit_annex]['+k+'][type]']=all_files[k].type;
              // _data['subject_answer['+i+'][submit_annex]['+k+'][shop_id]']=all_files[k].shop_id;
              _data['subject_answer['+i+'][submit_annex]['+k+'][url]']=all_files[k].store_path;
              _data['subject_answer['+i+'][submit_annex]['+k+'][name]']=all_files[k].file_name;

              _data['subject_answer['+i+'][submit_annex]['+k+'][subject_id]']=_this.list[i].id;
          }
        }

      }

      console.log( _data,_this.template_type)
      if(_this.template_type==1){
        console.log(_data)
        _this.tip_show('提交成功','success')
      }else if(_this.template_type==2 || _this.template_type==4){
        _this.is_ajax=true;
        _data.project_id=_this.project_id;
        _data.sample_id=_this.sample_id;
        let url="/api/Preview/submit_sample";


        if(_this.template_type==4){
          url="/agency/sample.Collect/submit_sample_formal";
          for(let item in _this.info_form){
            _data[item]=_this.info_form[item]
          }
          _data.status=_this.is_zc==1?1:2
        }


        _this.axios.post(url, _data).then(function(res) {
          if(res){
            _this.tip_show('提交成功','success');
            _this.$router.go(-1)
          }
          _this.is_ajax=false;
        }).catch(function(error) {
          console.log(error);
        })
      }



    },
    have_file(type,arr){
        let n=0;
        for(let i=0;i<arr.length;i++){
            if(arr[i].type==type){
                n++;
                break
            }
        }
        return n>0?true:false
    },
    handleClick(e){

    },
    to_ans(index){
      this.$refs.scrollbar.wrap.scrollTop=$('#item'+index).offset().top+$('.el-scrollbar__wrap').scrollTop()-$('.js_page_div').offset().top;
      // console.log()
      this.show_ans=false;
    },
    // 排他
    get_pt_indexs(answers){
        let indexs=[];
        for(let i=0;i<answers.length;i++){
            if(answers[i].is_exclude==1){
                indexs.push(i)
            }
        }
        return indexs;
    },

     sele_this(index1,index){
       if(this.is_view){return false;}
       const _this=this;
        // if(this.is_auto_sele){
        //     return false;
        // }
        let answers=this.list[index1].answer
        if(this.list[index1].type==1){
            for(let i=0;i<answers.length;i++){
                answers[i].is_sele=false
            }
            answers[index].is_sele=true;
            if(answers[index].is_open==1){
                // this.answers[index].constant=this.answers[index].answer_title
            }
        }else if(this.list[index1].type==2){
            let pt_indexs=this.get_pt_indexs(answers);
            if(pt_indexs.indexOf(index)!=-1){
                // 清除其他不带排他属性的选项
                let n=[];
                for(let i=0;i<answers.length;i++){
                    if(answers[i].is_exclude!=1 && answers[i].is_sele){
                        n.push(i+1)
                        answers[i].is_sele=false;
                    }
                }
                if(n.length>0){
                    _this.tip_show('根据排他规则'+n.join(',')+'选项被清除选择','warning')
                }
            }else{
                // 清除其他带排他属性的选项
                let n=[];
                for(let i=0;i<answers.length;i++){
                    if(answers[i].is_exclude==1 && answers[i].is_sele){
                        n.push(i+1)
                        answers[i].is_sele=false;
                    }
                }
                if(n.length>0){
                   _this.tip_show('根据排他规则'+n.join(',')+'选项被清除选择','warning')
                }
            }
            answers[index].is_sele=!answers[index].is_sele;
            if(answers[index].is_sele && answers[index].is_open==1){
                answers[index].constant=''
            }
            // 扣分时拦截，题库用的
            // this.try_show_tip(index)
        }
        this.list[index1].answer=answers
        this.$forceUpdate();
        this.get_jump(index1)
    },
    get_jump(index1){
      let ids=this.get_ids(index1,1);
      this.get_next_subject(this.list[index1].id,ids)
    },
    get_options(){

      // const _this=this;
      // this.loading = true;
      // _this.axios.get("/api/subject.SubjectOperate/subject_type_data", {params:{}}).then(function(res) {
      //   if(res){
      //     _this.types=res.message
      //   }
      // }).catch(function(error) {
      //   console.log(error);
      // })
    },

    // 获取下一题
    get_next_subject(id,ans){
        let list=this.list;
        console.log(id,ans)
        // 跳转下一题逻辑---
        // 找到当前是哪题
        let item={};
        let item_index=0;
        for(let i=0;i<list.length;i++){
            if(list[i].id==id){
                item=list[i];
                item_index=i;
                break;
            }
        }
        // 获取选项
        let obj_ans=item.answer;
        let jump_logic='';
        for(let i=0;i<ans.length;i++){
            for(let k=0;k<obj_ans.length;k++){
                if(obj_ans[k].answer_id==ans[i].answer_id){
                    // 获取跳转逻辑
                    jump_logic=obj_ans[k].jump_logic.type?obj_ans[k].jump_logic:'';
                    break;
                }

            }
            if(jump_logic){
              break;
            }
        }
        console.log(jump_logic,111)
        let tar_id='';
        if(jump_logic){
            let logic=jump_logic;
            console.log(logic)
            if(logic.type==1){
                tar_id=logic.subject_id
            }else{
                let rule=JSON.parse(logic.rules)
                let c=parseFloat(ans[0].constant || 0);
                console.log(rule)
                for(let i=0;i<rule.length;i++){
                    if(rule[i].symbol=='<'){
                        if(c<parseFloat(rule[i].constant)){
                            tar_id=rule[i].subject_id
                        }
                    }
                    if(rule[i].symbol=='>'){
                        if(c>parseFloat(rule[i].constant)){
                            tar_id=rule[i].subject_id
                        }
                    }
                    if(rule[i].symbol=='=='){
                        if(c==parseFloat(rule[i].constant)){
                            tar_id=rule[i].subject_id
                        }
                    }
                }
            }

        }
        let tar_index=null;
        console.log(tar_id)
        if(tar_id){
            for(let i=0;i<list.length;i++){
                if(list[i].id==tar_id){
                    tar_index=i;
                    break;
                }
            }
            // 先恢复
            if(this.list[item_index].jump_indexs){
              let jumps=this.list[item_index].jump_indexs;
              for(let i=0;i<this.list.length;i++){
                this.list[i].is_jump=false;
              }
            }

            let jump_indexs=[];
            // 后隐藏
            for(let i=item_index+1;i<tar_index;i++){
              if(this.list[i]){
                this.list[i].is_jump=true;
                jump_indexs.push(i)
              }
            }
            this.list[item_index].jump_indexs=jump_indexs;
        }else{
            tar_index=item_index+1
        }


        // if(tar_index!=null){
        //     if(tar_index<=list.length-1){
        //         let next_item=list[tar_index];

        //         return {data:{subject_info:next_item}}
        //     }else{
        //         return {data:{subject_info:[]}}
        //     }
        // }else{
        //     return {data:{subject_info:[]}}
        // }
    },
    /** 查询定时任务列表 */
    getList() {
      const _this=this;
      this.loading = true;
      let url;
      let _data={};
      let ajax
      if(_this.template_type==1){
        url="/api/Preview/get_subject_join_subject_all";
        _data={q_id:this.id};
        ajax=_this.axios.get(url, {params:_data});
      }
      if(_this.template_type==2){
        url="/api/Preview/begin_answer_get_all_subject";
        _data={project_id:this.project_id};
        ajax=_this.axios.post(url, _data);
      }
      if(_this.template_type==4){
        url="/agency/sample.Collect/begin_answer_formal_all_subject";
        _data={project_id:this.project_id,sample_id:this.id};
        ajax=_this.axios.post(url, _data);
      }
      ajax.then(function(res) {
        if(res){
          let datalist;
          if(_this.template_type==1){
            datalist=res.message;
          }else if(_this.template_type==2){
            datalist=res.data.subject_list;
            _this.sample_id=res.data.sample_id
          }else if(_this.template_type==4){
            // if(_this.id){
              _this.sample_id=res.data.sample_id
            // }else{
              datalist=res.data.subject_list;
            // }

          }
          _this.deal_list(datalist)
          _this.loading = false;
        }
      }).catch(function(error) {
        console.log(error);
      })
    },
    del_old(list){
      let arr=[];
      for(let i=0;i<list.length;i++){
        let index=this.old_answers.findIndex(v=>v.id==list[i].id);
        if(index==-1){
          arr.push(list[i])
        }else{
          let item=this.old_answers[index];
          console.log(item)
          list[i].files=item.main_annex.map(v=>{
            let obj={
              store_path:'storage/'+v.url.split('/storage/')[1],
              file_name:v.name,
              type:v.type
            }
            return obj
          })


          for(let k=0;k<list[i].answer.length;k++){
            list[i].answer[k].is_sele=item.answer[k].is_choose==1?true:false;
            list[i].answer[k].constant=item.answer[k].constant;
          }
          arr.push(list[i])
        }
      }
      return arr;
    },
    deal_list(datalist){
      console.log(datalist)
      const _this=this;
      let list=[]
      for(let i=0;i<datalist.length;i++){
        for(let k=0;k<datalist[i].list.length;k++){
          if(k==0){
            datalist[i].list[k].cate_tt=datalist[i].title
          }
          datalist[i].list[k].is_jump=false; // 是否被跳过
          datalist[i].list[k].pid_index=i;
          datalist[i].list[k].node_index=k;
          datalist[i].list[k].files=[];
          datalist[i].list[k].min_change=datalist[i].list[k].min_change==0?1:parseInt(datalist[i].list[k].min_change);
          datalist[i].list[k].max_change=datalist[i].list[k].max_change==0?100:parseInt(datalist[i].list[k].max_change);
          datalist[i].list[k].answer.map(v=>{v.is_sele=(datalist[i].list[k].type==3 || datalist[i].list[k].type==4)?true:false;v.is_error=false;v.constant=""})
          list.push(datalist[i].list[k])
        }
      }
      if(_this.template_type==4){
        _this.list = this.del_old(list);
      }else{
        _this.list = list
      }
      console.log(list)
      _this.cate=datalist;
      if(_this.cate.length>0){
        _this.activeName=_this.cate[0].id.toString()
      }
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.color_blue{color: #056DFF;}
.answers_list .item{background: #fff;border-radius: 4px; margin-bottom: 0;}
.answers_list .item .tt{background: #fff; padding: 12px 0; font-size: 16px;}
.answers_list .ans{  overflow: hidden; padding: 0px; font-size: 14px;}
.answers_list .ans .item_d{width:auto; padding: 5px 0; cursor: pointer;}

.answers_list.move_item .item .el-checkbox{display: none;}
.answers_list.move_item .item{cursor: move;user-select:none; position: relative;}
.answers_list.move_item .item a{display: none;}
.answers_list.move_item .item a.js_sort{display: flex;}
.answers_list.move_item .item .ans{display: none;}
.answers_list.move_item .item{margin-bottom: 10px;}
.zhuan_span{background:#FFEACB; color: #1F2329; line-height: 28px; padding: 0 12px 0 0; display: inline-block; border-radius: 28px;}
.zhuan_span img{width: 24px; margin-right: 7px; margin-left: 2px; margin-top: 2px; float: left;}
/* .js_sort{cursor: move;}
.js_sort img{ -webkit-user-select:none;pointer-events: none;-webkit-user-drag: none;
  -moz-user-selectt:none;
  -khtml-user-selectt:none;
  -ms-user-selectt:none;} */
.tab_ans_list a{display: block; margin-right: 5px; margin-bottom: 5px; color: #666; text-align: center; line-height: 30px; width: 32px; border: 1px solid #eee;}
.tab_ans_list a:hover{color: #004EA2; border-color: #004EA2;}
.moni_radio{width: 20px;height: 20px; display: flex; align-items: center; border-radius: 50%;justify-content: center; margin-right: 10px;border: 1px solid #ccc;}
.moni_radio:after{content: ""; display: block; width: 10px; height: 10px; border-radius: 50%; background: #ccc; }
.moni_radio.check{border-radius: 3px;}
.moni_radio.check:after{border-radius: 3px;}
.moni_radio.active{border-color:  #056DFF;}
.moni_radio.active:after{background:  #056DFF;}

.pdflist{display: grid; grid-template-columns: 1fr 1fr;gap:20px 30px; }
.pdflist .icon{height: 32px;}
.pdflist .pdfitem{border: 1px solid #D5D5D5; border-radius: 6px; padding:8px 15px; font-size: 14px; margin-top: 5px;}
.pdflist .disabled .icon{filter: grayscale(1);}
.pdflist .pdfitem .op_btn{font-size: 14px; color: #555555; line-height: 18px; transition: 0.3s; padding: 0 17px; border-left: 1px solid #BBBBBB;}
.pdflist .pdfitem .op_btn:hover{transform: translateY(-1px);}
.pdflist .pdfitem .op_btn:first-child{border-left: none;}
.pdflist .pdfitem .op_btn img{height: 16px; margin-right: 4px;}

.cate_tt{background: #F2F3F5; padding: 0 20px; line-height: 40px; font-size: 18px; color: #1D2129; margin: 10px 0;}
.ans_type{border-radius: 3px; border: 1px solid #aaa; color: #555; font-size: 13px; padding: 0 6px; line-height: 22px; vertical-align: center;}
.up_div .upbtn{border: 1px solid #325FFF; margin-right: 10px; border-radius: 4px; padding: 0 16px; font-size: 14px; color: #325FFF; line-height: 30px;}
.up_div .upbtn img{height: 13px; margin-right: 5px;}
.ans_it{font-size: 14px; margin-bottom: 3px;}
.ans_item{padding:12px 0; border-bottom: 1px solid #eee;}
/deep/.answers_list .line_input input.el-input__inner{ border: none; border-radius: 0; border-bottom: 1px solid #888; padding: 0 5px;}
</style>
